import java.util.Properties

import org.apache.flink.api.common.serialization.SimpleStringSchema
import org.apache.flink.streaming.api.scala.StreamExecutionEnvironment
import org.apache.flink.streaming.connectors.kafka.FlinkKafkaConsumer
import org.apache.flink.api.scala._

object readKafka {
  def main(args: Array[String]): Unit = {
    val env = StreamExecutionEnvironment.getExecutionEnvironment



    val prop = new Properties()
    prop.setProperty("bootstrap.servers", "192.168.1.23:9092")
    prop.setProperty("group.id", "test1")
    val kafkaConsumer = new FlinkKafkaConsumer[String](
      "zhikaiTest1"
      , new SimpleStringSchema()
      , prop)
    kafkaConsumer.setStartFromEarliest()
    env.addSource(kafkaConsumer
    ).print()

    env.execute()

  }

}
